
	$(document).ready(function(){
       loadData(-1,1);
	});

function loadData(type,pageNo){
	console.log(11)
	$("#thislist").html("");
	   $.ajax({  
        type : "get",  
        url : urlcore + "/api/test/getTestListWithPage?type="+type+"&pageNum="+pageNo+"&pageSize="+pageSize, 
        dataType : "json",
        headers:{"Content-Type":"application/json;charset=UTF-8"},
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	if(data.success==true){
        		    var da=data.data.list;
        			var html="" , title="",isMore="",score="",gmtDatetime="",index=1,id="";
					for(var i=0;i<da.length;i++){
						index++;
						id=da[i].id;
						title=da[i].title;
						isMore=da[i].isMore==1?"多选":"单选";
						score=da[i].score;
						gmtDatetime=new Date(da[i].gmtDatetime).pattern("yyyy-MM-dd hh:mm:ss");
					html+=  "  <tr id=\""+id+"\">\n" +
							"  \t\t<td>"+index+"</td>\n" + 
							  "  \t\t<td>"+title+"</td>\n" + 
				            "  \t\t<td>"+isMore+"</td>\n" + 	
							"  \t\t<td>"+score+"</td>\n" + 			
							"  \t\t<th>"+gmtDatetime+"</th>\n" + 
							"  \t\t<td>\n" + 
							"  \t\t\t<a class=\"btn btn-primary btn-xs\" href=\"up_test.html?id="+id+"\"> 修改</a>\n" + 
							"   \t\t\t<a class=\"btn btn-primary btn-xs\" href=\"javascript:;\" onclick=\"doDelete("+id+")\"> 删除</a>\n" + 
							"  \t\t</td>\n" + 
							"  \t</tr>";
					}
				$("#thislist").append(html);
        		$('#thiscount').text(data.data.total);
        		$("#pager").pager({
					pagenumber: pageNo, 
					pagecount:data.data.pages,
					totalcount:data.data.total,
					buttonClickCallback: PageClick
				}); 
        	}else if (data.code == 'OVERTIME') {
                var thisUrl = window.location.href;
                if (thisUrl.indexOf('login.html') <= -1) {
                    top.window.location.href = "login.html";
                }
            } else {
                alert(data.msg);
            }
        },
        error:function(){  
            alert("上传失败");  
        }  
    }); 
	
}


//回调函数  
PageClick = function(pageclickednumber) {  
var type =$('#goods_type option:selected') .val();//选中的值
      loadData(type,pageclickednumber);
}



//刪除
function doDelete(id){
		   $.ajax({  
	        type : "get",  
	        url : urlcore + "/api/test/deleteTest?testId="+id, 
	        dataType : "json",
	        headers:{"Content-Type":"application/json;charset=UTF-8"},
	        data : {},
	        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
	        	if(data.success==true){
	        		location.reload();
	        	}else {
	                alert(data.msg);
	            }
	        },
	        error:function(){  
	            alert("上传失败");  
	        }  
    }); 
	
}



//搜索
function searchuser() {
	var type =$('#goods_type option:selected') .val();//选中的值
      loadData(type,1);
}


